package com.dragon.shop_order.controller;

import com.dragon.shop_common.utils.AjaxResult;
import com.dragon.shop_order.domain.param.GetOrderNoParam;
import com.dragon.shop_order.domain.vo.GetOrderNoVo;
import com.dragon.shop_order.service.IOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private IOrderService orderService;


    @GetMapping("/getOrderNo")
    public AjaxResult<String> getOrderNo() {
        return AjaxResult.succeedWith("你的订单号是：3289458056906505699");
    }

    @GetMapping("/getOrderNo2")
    public AjaxResult<GetOrderNoVo> getOrderNo2(String userId) {
        return AjaxResult.succeedWith(GetOrderNoVo
                .builder()
                        .userId(userId)
                        .orderNo("222222222222222222")
                .build()
        );
    }

    @GetMapping("/getOrderNo3")
    public AjaxResult<GetOrderNoVo> getOrderNo3(GetOrderNoParam getOrderNoParam) {
        return AjaxResult.succeedWith(GetOrderNoVo
                .builder()
                .userId(getOrderNoParam.getUserId())
                .orderNo("3333333333333")
                .build()
        );
    }

    @PostMapping("/getOrderNo4")
    public AjaxResult<GetOrderNoVo> getOrderNo4(GetOrderNoParam getOrderNoParam) {
        return AjaxResult.succeedWith(GetOrderNoVo
                .builder()
                .userId(getOrderNoParam.getUserId())
                .orderNo("4444444444444444")
                .build()
        );
    }

    @PostMapping("/getOrderNo5")
    public AjaxResult<GetOrderNoVo> getOrderNo5(@RequestBody GetOrderNoParam getOrderNoParam) {
        return AjaxResult.succeedWith(GetOrderNoVo
                .builder()
                .userId(getOrderNoParam.getUserId())
                .orderNo("55555555555555555")
                .build()
        );
    }

    @GetMapping("/createOrder")
    public AjaxResult<String> createOrder(String userId) {
        return orderService.createOrder(userId);
    }

}
